﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace GhostStory.Model
{
    class Player
    {
        Vector2 m_speed = new Vector2(0f, 0);
        //Vector2 m_position = new Vector2(0f, 0);
        public Vector2 m_sizes = new Vector2(0.8f, 0.8f);
        Vector2 m_centerBottomPosition = new Vector2(2, 7);
        private int points = 0;
        Collider m_collider;

        public Player()
        {
            m_collider = new Collider(new Vector2(m_centerBottomPosition.X, m_centerBottomPosition.Y - (m_sizes.Y / 2)), m_sizes.Y / 2);
        }

        internal void Update(float a_elapsedTime)
        {
            Vector2 gravityAcceleration = new Vector2(0.0f, 9.82f);

            //integrate position
            m_centerBottomPosition = m_centerBottomPosition + m_speed * a_elapsedTime + gravityAcceleration * a_elapsedTime * a_elapsedTime;

            //integrate speed
            m_speed = m_speed + a_elapsedTime * gravityAcceleration;
        }

        internal Collider getCollider()
        {
            return m_collider;
        }

        internal float getRadius()
        {
            return this.m_sizes.Y / 2;
        }


        internal void DoJump()
        {
            m_speed.Y = -7; //Jump upwards
        }

        internal void WalkRight()
        {
            m_speed.X = 7.0f;
        }

        internal void WalkLeft()
        {
            m_speed.X = -1.0f;
        }

        internal void Stop()
        {
            m_speed.X = 0;
        }

        internal Vector2 getPosition()
        {
            return m_centerBottomPosition;
        }

        internal void setPosition(float a_x, float a_y)
        {
            m_centerBottomPosition.X = a_x;
            m_centerBottomPosition.Y = a_y;
        }

        internal Vector2 getSpeed()
        {
            return m_speed;
        }

        internal void setSpeed(float a_x, float a_y)
        {
            m_speed.X = a_x;
            m_speed.Y = a_y;
        }

        internal void addPoints(int points)
        {
            this.points = this.points + points;
        }

        internal void resetPoints()
        {
            this.points = 0;
        }

        internal int getPoints()
        {
            return this.points;
        }

    }
}
